# -*- coding:utf-8 -*-
import httplib, urllib
 
#定义需要进行发送的数据   
#定义一些文件头   
headers = {"Content-Type":"application/x-www-form-urlencoded",   
                   "Connection":"Keep-Alive","Referer":"http://127.0.0.1/"};   
#与网站构建一个连接   
conn = httplib.HTTPConnection("127.0.0.1", 8080);   
#开始进行数据提交   同时也可以使用get进行   
params = urllib.urlencode({'type':'register','code':'5bCP5rC054mbOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2OjE6MTk4Mw=='}); 
conn.request(method="POST",url="/user",body=params, headers=headers);   
#返回处理后的数据   
response = conn.getresponse(); 
#判断是否提交成功   
print response.status
print response.read()

conn = httplib.HTTPConnection("127.0.0.1", 8080);   
params = urllib.urlencode({'type':'checkin','code':'5bCP5rC054mbOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2'}); 
conn.request(method="POST",url="/user",body=params, headers=headers);   
#返回处理后的数据   
response = conn.getresponse(); 
#判断是否提交成功   
print response.status
print response.read()
conn.close();
